import { eventBus, logger } from '@/instance'
import { messageTypeMap, eventsMap } from '@/constants'
export default {
  install() {
    window.addEventListener('message', (e) => {
      const payload = e.data
      logger.log('adapters/message', 'handleMessage', payload)
      switch (payload.type as messageTypeMap) {
        case messageTypeMap.CLIP_DRAGSTART:
          eventBus.emit(eventsMap.THIRD_DRAGSTART, payload)
          break
        case messageTypeMap.CLIP_DRAGEND:
          eventBus.emit(eventsMap.THIRD_DRAGEND, payload)
          break
        default:
          break
      }
    })
  },
}
